package com.zy.baselib

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.sudworth.themvp.model.EmptyModel
import com.sudworth.themvp.model.IModel
import com.sudworth.themvp.view.IDelegate

/**
 * 不需要使用model可以继承这个类
 * ui操作写在IDelegate
 */
abstract class BaseDiVAct<V: IDelegate>: BaseDiVMAct<V, EmptyModel>()

abstract class BaseDiAct<B: ViewBinding> : BaseDiMAct<B, EmptyModel>()

/**
 * 使用 Model,但是ui写在activity中
 */
abstract class BaseDiMAct<B: ViewBinding, M: IModel>: BaseDiVMAct<EmptyAppDelegate<B>, M>() {

    private lateinit var mViewBinding: B

    override fun canViewBinding(): Boolean {
        return true
    }

    override fun onResetContentView(): View {
        mViewBinding = onCreateVB(layoutInflater, null)
        return mViewBinding.root
    }

    abstract fun onCreateVB(inflater: LayoutInflater, container: ViewGroup?): B

    fun getViewBinding(): B {
        return mViewBinding
    }
}